<?php


/**
 *
 * delay.php?f=file.js&t=100
 *
 * 延时100毫秒加载file.js
 *
 * */

//得到扩展名
function get_extend($file_name) { 
	$extend =explode("." , $file_name);
	$va=count($extend)-1;
	return $extend[$va];
} 
 
/**
 * begin
 */
//cdn上存在的各种可能的文件类型
$header = array(
    'js' => 'Content-Type: application/x-javascript',
    'css' => 'Content-Type: text/css',
    'jpg' => 'Content-Type: image/jpg',
    'gif' => 'Content-Type: image/gif',    
    'png' => 'Content-Type: image/png',
    'jpeg' => 'Content-Type: image/jpeg',
    'swf' => 'Content-Type: application/x-shockwave-flash'
);


$filename = $_GET['f'];
$R_files = file($_GET['f']);

if(empty($type)) {
	$type = get_extend($filename);
}

header($header[$type]);

ob_flush();
flush();
sleep($_GET['t']);

//var_dump($R_files);


echo join("\n",$R_files);

?>

